package com.ruoyi.back.controller

import com.ruoyi.app.common.Data
import com.ruoyi.app.common.PageData
import com.ruoyi.app.common.pageInfo
import com.ruoyi.back.domain.dto.UserListSearchDto
import com.ruoyi.back.domain.vo.UserDetailVo
import com.ruoyi.back.domain.vo.UserListVo
import com.ruoyi.back.service.AppUserService
import com.ruoyi.common.core.controller.BaseController
import io.swagger.annotations.*
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.*

@RestController
@RequestMapping("/system/appUser")
@Api(tags = ["用户信息"])
class AppUserController : BaseController() {

    @Autowired
    private lateinit var appUserService: AppUserService


    @ApiOperation("后台管理系统获取app用户列表")
    @GetMapping("list")
    fun selectAppUserList(userListSearchDto: UserListSearchDto): PageData<UserListVo> = appUserService.selectAppUserList(userListSearchDto).pageInfo()

    @ApiOperation("获取app详情信息")
    @ApiImplicitParams(
        ApiImplicitParam(name = "userId", value = "用户id", type = "path", required = true)
    )
    @GetMapping("get/{userId}")
    fun appUserDetail(@PathVariable userId: Long): Data<UserDetailVo> = appUserService.appUserDetail(userId)


    @ApiOperation("冻结app用户")
    @ApiImplicitParams(
        ApiImplicitParam(name = "userId", value = "用户id", type = "path", required = true)
    )
    @PostMapping("freezeUser/{userId}")
    fun freezeAppUser(@PathVariable userId: Long): Data<Boolean> = appUserService.freezeAppUser(userId)

    @ApiOperation("移除app用户")
    @ApiImplicitParams(
        ApiImplicitParam(name = "userIds", value = "用户id 多个使用逗号隔开", type = "path", required = true)
    )
    @PostMapping("remove/{userIds}")
    fun removeAppUser(@PathVariable userIds: String): Data<Boolean> = appUserService.removeAppUser(userIds)

    @ApiOperation("取消用户会员")
    @ApiImplicitParams(
        ApiImplicitParam(name = "userIds", value = "用户id", type = "path", required = true)
    )
    @PostMapping("cancel/{userId}")
    fun cancelMember(@PathVariable userId: Long): Data<Boolean> = appUserService.cancelMember(userId)

}